package com.sunlands.qdcy.tongzhuo.vo;

import com.sunlands.qdcy.tongzhuo.constant.CommonResultMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class BusinessResult<T> implements Serializable {

    private Long code;

    private String message;

    private T data;

    public static <T> BusinessResult<T> createSuccessInstance(T data) {
        return new BusinessResult<>(CommonResultMessage.SUCCESS.code, CommonResultMessage.SUCCESS.message, data);
    }


    public static <T> BusinessResult<T>  createInstance(CommonResultMessage message) {
        return new BusinessResult<>(message.getCode(), message.getMessage(), null);
    }

    public static <T> BusinessResult<T>  createInstance(CommonResultMessage message,T data) {
        return new BusinessResult<>(message.getCode(), message.getMessage(), data);
    }

    public static <T> BusinessResult<T>  createInstance(Long code,String message,T data) {
        return new BusinessResult<>(code, message, data);
    }
    public static <T> BusinessResult<T> createInstance(Long code,String message) {
        return new BusinessResult<>(code, message, null);
    }
}
